import 'package:flutter/material.dart';

import 'package:kq_flutter_core_widget/widgets/button/kq_ink_well.dart';

import '../../../router/route_map.dart';

/// 首页
class HomePage extends StatelessWidget {
  const HomePage({super.key});

  /// 菜单布局
  Widget gridMenuItem(String menuName, GestureTapCallback? onTap) {
    return KqInkWell(
      radius: 20,
      borderWidth: 2,
      borderColor: Colors.red,
      onTap: onTap,
      child: Container(
        color: Colors.white,
        padding: const EdgeInsets.all(10),
        child: Text(
          menuName,
          style: const TextStyle(
            fontWeight: FontWeight.bold,
            color: Colors.black,
            fontSize: 20,
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('核心库演示'),
      ),
      body: GridView.count(
        crossAxisCount: 2,
        scrollDirection: Axis.vertical,
        //宽高比
        childAspectRatio: 3 / 1.2,
        padding: const EdgeInsets.all(12),
        mainAxisSpacing: 12,
        crossAxisSpacing: 12,
        children: [
          gridMenuItem('表格', () {
            RouteMap.pushTableDemo();
          }),
          gridMenuItem('表格-拆分单元格', () {
            RouteMap.pushTableSplitCell();
          }),
          gridMenuItem('图表', () {
            RouteMap.pushChartPage();
          }),
          gridMenuItem('蓝牙', () {
            RouteMap.pushBleDemoState();
          }),
        ],
      ),
    );
  }
}
